<template>
    <div class="page-spec-detail" v-if="getProductDetail">
        <!-- banner -->
        <VideoBanner v-if="getProductDetail"
            :images="[getProductDetail.cover]" />
        <!-- 详情-->
    <!-- <div> -->
        <div class="info">
            <div class="inner">
                <div class="header">
                    <div class="fl-box">
                        <div class="price-box">
                            <div class="price">¥{{getProductDetail.price/100}}/件</div>
                            <div class="des" v-if="getProductDetail.discount !== 100">{{'选择该产品享' + (getProductDetail.discount / 10) + '折扣'}}</div>
                        </div>
                        <div class="title normal-text grey-text-color">{{getProductDetail.value}}</div>
                    </div>
                    <!-- <div class="fr-box">
                        <Stepper :value="getProductDetail.number" :val-index="valIndex" @change="onNumberChange" :can-change="canOptionDel" />
                    </div> -->
                </div>
                <div class="desc">
                    <div class="giant-text">PRODUCT DETAILS</div>
                    <div class="gianttext">产品详情</div>
                </div>
            </div>
        </div>
        <div class="detail-description text-small">
            <RichText :content="getProductDetail.description"></RichText>
        </div>
    </div>
</template>

<script lang="ts">
import {
    formatRichText,
} from '@/lib/utils';
import VideoBanner from '@/components/common/videoBanner.vue';
import LineTitle from '@/components/common/lineTitle.vue';
import Stepper from '@/features/pkg/stepper.vue';
import store from '@/store';
import { Component, Vue } from 'vue-property-decorator';

import { Route } from 'vue-router';

@Component({
    name: 'productDetail',
    components: {
        VideoBanner,
        LineTitle,
        Stepper,
    },
})
export default class ProductDetail extends Vue {
    public productId = null;
    public pid = null;

    public get getProductDetail(){
        return store.state.shop.productDetail;
    }


    public async beforeRouteEnter(to: Route, from: Route, next: any) {
        store.commit('utils/startRequest');
        await store.dispatch('shop/getProductDetail', {
            productId: to.query.productId,
        });
        store.commit('utils/endRequest');
        next();
    }

    public async created() {
        if (!this.getProductDetail) {
            wx.navigateBack();
        }
    }

}
</script>

<style lang="less">
@import "../../lib/style/mixins.less";

.page-spec-detail {
    .info {
        padding: 10px 16px 0;
        background-color: @white-color;
        .title {
            padding-bottom: 10px;
        }
        .price-box {
            display: flex;
            // justify-content: space-between;
            align-items: center;
            color: #f4051a;
            .price {
                font-size: 48rpx;
            }
            .des {
                margin-left: 10px;
                font-size: 24rpx;
            }
        }
        .desc {
            padding: 10px 0;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid #bbbbbb;
            .fl-box {
                flex: 1;
            }
            .fr-box {
                width: 200rpx;
                display: flex;
                justify-content: flex-end;
            }
        }
    }
    .fixed-btn-wrap {
        padding: 20rpx 40rpx;
        // box-sizing: border-box;
        // position: fixed;
        // left: 0;
        // bottom: 0;
        // width: 100%;
        // padding: 20rpx 24rpx;
        // background: rgba(1, 8, 36, 0.48);
        // display: flex;
        // align-items: stretch;
        // justify-content: flex-end;

        // .price {
        //     display: flex;
        //     flex: 1;
        //     align-items: center;
        //     padding: @button-large-padding-v 14px;
        //     line-height: @button-large-line-height;
        //     box-sizing: border-box;
        //     &.safe {
        //         padding-bottom: @button-large-padding-v + @button-safe-padding-bottom;
        //     }
        // }
        // .btn {
        //     width: 113px;
        //     border-radius: 0;
        //     text-align: center;
        // }
        // .mr-right-20 {
        //     margin-right: 20rpx;
        // }
    }
}

</style>
